-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Frontend] Generalise SourceCodeFile class #1997
[Frontend] Generalise SourceCodeFile class #1997
Conversation
Signed-off-by: Arthur Chan <[email protected]>
Signed-off-by: Arthur Chan <[email protected]>
Signed-off-by: Arthur Chan <[email protected]>
Signed-off-by: Arthur Chan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will land this and adjust some of these things myself
|
||
class SourceCodeFile(): | ||
"""Class for holding file-specific information.""" | ||
LANGUAGE: dict[str, Language] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LANGUAGE
is too generic of a name here
LANGUAGE: dict[str, Language] = { | ||
'c': Language(tree_sitter_c.language()), | ||
'cpp': Language(tree_sitter_cpp.language()), | ||
'c++': Language(tree_sitter_cpp.language()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use language constants from constants.py
here
with open(self.source_file, 'rb') as f: | ||
self.source_content = f.read() | ||
|
||
# Initialization ruotines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
self.root = self.parser.parse(self.source_content).root_node | ||
|
||
def language_specific_process(self): | ||
"""Dummy function to perform some specific processes in subclasses.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am not sure if we should use dummy
here, or just give documentation as how classes inherit from here should use the function
|
||
logger = logging.getLogger(name=__name__) | ||
|
||
|
||
class SourceCodeFile(): | ||
class CppSourceCodeFile(SourceCodeFile): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have the language post SourceCodeFile
here, this applies to the other classes as well.
This PR generalise the SourceCodeFile classes and simplify some of the frontend logic.